// pages/mystu/mystu.js
var app = getApp()
var httpUtils = require('../../utils/httpUtils')
var api = require("../../utils/API")
var utils = require("../../utils/utils")
var commonFields = require("../../utils/commonFields")
Page({

    /**
     * 页面的初始数据
     */
    data: {
        students: [],
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        this.requestMyStuData()
    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function () {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },

    requestMyStuData() {
        let that = this;
        httpUtils.postRequest(api.API_USER_MYSTU, {},
            res => {
                console.log(res)
                res.data.forEach(function (element, index, array) {
                    // element: 指向当前元素的值
                    // index: 指向当前索引
                    // array: 指向Array对象本身
                    that.data.students.push(element)
                });
                that.setData({
                    students: that.data.students,
                })
                console.log(that.data.students)
            },
            fail => {
                console.log(fail)
            })
    },
})
/*

{
    HeadImage:null
    Id:25
    IsDel:0
    IsVip:0
    JoinBy:"super"
    JoinDate:"2018-10-15T13:37:49"
    Mobile:"13641426766"
    Name:"李继民"
    Openid:null
    ParentId:58
    Password:"6766"
    RebateCash:0
    RebatePercent:0
    ShareCode:null
    Status:1
    Unionid:null
    UpdateBy:"super"
    UpdateDate:"2018-12-12T11:27:46"
    UserType:1
    VipEnd:"2018-10-25T13:37:44"
    VipStart:"2018-10-15T13:37:44"
    Web_AgentId:5
    Web_VipId:1
    WxHeadImg:null
    WxName:null
}
*/
